home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Graphics 3D / RAVE Starter Samples / RAVE CommonCode / Common Stuff.h next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.4 KB  |  79 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Common Stuff.h
  3.  
  4.     Contains:    This is a standard set of includes and macros that are defined for all of the RAVE
  5.                 projects, including error checking code and debugging features.
  6.  
  7.     Written by: Timothy Carroll    
  8.  
  9.     Copyright:    Copyright ©1996-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 7/15/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24.  
  25. #ifndef _COMMONSTUFF_
  26. #define _COMMONSTUFF_
  27.  
  28. #pragma once
  29.  
  30. // RAVE needs enums always int to be turned on
  31. #ifdef __MWERKS__
  32.  
  33.     #if !__option (enumsalwaysint)
  34.         #error "Enums must be always int for RAVE to work properly"
  35.     #endif
  36. #endif
  37.  
  38. /*********************************************************************************
  39. #    ERROR HANDLING MACROS
  40. #
  41. #    These macros can be used to implement nice error handling within a function.
  42. #    Essentially, all errors jump to an error handler at the end of the function, which
  43. #    should cleanup  any leftovers and return the appropriate error result.
  44. #
  45. #    Note that the error handlers take a message string.  This should be a good
  46. #    indication of the actual error, and it will appear when debugging is turned on.
  47. #
  48. #    The qDebugging macro can be used to implement sanity checking code that is only
  49. #   compiled into debug builds.
  50. #
  51.     
  52.     #if qDebugging
  53.           // do additional sanity checking here.
  54.     #endif
  55. #
  56. #    This could be used to check the internal validity of an object before acting on it
  57. #    
  58. *********************************************************************************/
  59. #ifndef qDebugging
  60.     #define qDebugging 1
  61. #endif
  62.  
  63. #if qDebugging
  64.     #define SIGNAL_ERROR(msg)        {DebugStr(msg); goto error;}
  65. #else
  66.     #define SIGNAL_ERROR(msg)        {goto error;}
  67. #endif
  68.  
  69. #define FAIL_NIL(y,msg)            if (y == NULL) SIGNAL_ERROR(msg)
  70. #define FAIL_OSERR(y,msg)        if (y != noErr) SIGNAL_ERROR(msg)
  71. #define FAIL_FALSE(y,msg)        if (!y) SIGNAL_ERROR(msg)
  72.         
  73.  
  74.  
  75. #endif /* _COMMONSTUFF_ */
  76.  
  77.     
  78.  
  79.